<template>
  <div>
<h2>门店的录入</h2>
<table border="1">
  <tr>
    <td>门店昵称</td>
    <td>
      <input type="text" v-model="state.name">
    </td>
  </tr>
  <tr>
    <td>门店地址</td>
    <td>
      <input type="text" v-model="state.address">
    </td>
  </tr>
  <tr>
    <td>联系方式</td>
    <td>
      <input type="text" v-model="state.phone">
    </td>
  </tr>
 
  <tr>
    <td>门店营业时间</td>
    <td>
      <input type="date" v-model="state.sdate">
    </td>
  </tr>
  <tr>
    <td>门店休息时间</td>
    <td>
      <input type="date" v-model="state.edate">
    </td>
  </tr>
  <tr>
    <td>门店类型</td>
    <td>
      <input type="text" v-model="state.type">
    </td>
  </tr>
  <tr>
    <td></td>
    <td>
      <input type="button" @click="add" value="添加">
    </td>
  </tr>
</table>
  </div>
</template>

<script setup lang="ts">
import { reactive,toRefs,onMounted } from 'vue';
import axios from 'axios';
import { useRoute,useRouter } from 'vue-router';
let route=useRoute();
let router=useRouter();
let data=reactive({
  state:{
   name:'',
   address:'',
   phone:'',
   phonto:'',
   sdate:'',
   edate:'',
   type:''
  }
})
let {state}=toRefs(data)


function add()
{
  let obj={
  "name":    state.value.name,
  "address": state.value.address,
  "phone":   state.value.phone,
  "phonto":  state.value.phonto,
  "sdate":   state.value.sdate,
  "edate":   state.value.edate,
  "type":    state.value.type
  }
  if(state.value.name=="")
  {
    alert("门店昵称不能为空")
    return;
  }
 
  axios({
    url:'/api/MenDian/MenDiaAdd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.data==1)
  {
    alert("添加成功")
    router.push("../mshow")
  }
else
{
  alert("添加失败")
}
  })
  .catch(err=>{

  })
}
</script>

<style scoped>

</style>